from pathlib import Path
import os
import sys
import django
from django.db import transaction
from datetime import datetime
from datetime import timedelta
BASE_DIR=Path(__file__).parent.parent.parent
sys.path.append(BASE_DIR)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myauction.settings')
django.setup()
from api import models
with transaction.atomic():
    auction_object=models.Auction.objects.create(title='烟酒专场',
                                  cover='封面图片地址',
                                  preview_start_time=datetime.now(),
                                  preview_end_time=datetime.now()+timedelta(hours=48),
                                  auction_start_time=datetime.now() + timedelta(hours=48),
                                  auction_end_time=datetime.now() + timedelta(hours=50),
                                  deposit=1000,
                                  goods_count=2
                                  )
    auction_1=models.AuctionItem.objects.create(
        auction=auction_object,
        uid='20230221203332',
        title = '飞天茅台',
        cover = '茅台封面',
        start_price=1499,
        highest_price=1999,
        reserve_price=1599,
        deposit=200,
        unit=100
    )
    auction_2 = models.AuctionItem.objects.create(
        auction=auction_object,
        uid='20230221203343',
        title='五粮液',
        cover='五粮液封面',
        start_price=799,
        highest_price=1399,
        reserve_price=999,
        deposit=200,
        unit=100
    )
    image_1=models.AuctionItemImage.objects.create(
        item=auction_1,
        img = '拍品图片1-1',
        carousel=True,
        order=1
    )
    image_2 = models.AuctionItemImage.objects.create(
        item=auction_1,
        img='拍品图片1-2',
        carousel=True,
        order=2
    )
    image_3 = models.AuctionItemImage.objects.create(
        item=auction_2,
        img='拍品图片2-1',
        carousel=True,
        order=1
    )
    image_4 = models.AuctionItemImage.objects.create(
        item=auction_2,
        img='拍品图片2-2',
        carousel=True,
        order=2
    )
    detail_1=models.AuctionItemDetail.objects.create(
        item=auction_1,
        key='品牌',
        value='茅台'
    )
    detail_2 = models.AuctionItemDetail.objects.create(
        item=auction_1,
        key='产地',
        value='贵州'
    )
    detail_3 = models.AuctionItemDetail.objects.create(
        item=auction_2,
        key='品牌',
        value='五粮液'
    )
    detail_4 = models.AuctionItemDetail.objects.create(
        item=auction_2,
        key='产地',
        value='宜昌'
    )
#提取码：trwn
#解压密码：tiaokan.vip
#提取码：dw9f 解压密码：昼夜宣yin